#pragma once
#include "AppConfig.h"
#include "RegisterAppInfo.h"
#include "faxUsbManager.h"
#include "shellapi.h"

typedef AppConfig *(*PFNCreateAppConfigObject)();
typedef BOOL (*PFNInitAppRegisterInfo)();
typedef RegisterAppInfo* (*PFNCreateRegisterAppInfoObject)();
typedef BOOL (*PFNGetAppRegisterInfoByExePath)( char *exePath, RegisterAppInfo &info );
typedef BOOL (*PFNGetAppRegisterInfoByinstallPath)( char *installPath, RegisterAppInfo &info );
typedef BOOL (*PFNGetConfigBySerialNum)(char *serialNum, AppConfig &config);
typedef BOOL (*PFNIsOtherInstanceRunning)();
typedef CfaxUsbManager* (*PFNGetTaxUsbManager)();
typedef BOOL (*PFNGetPassword)(char* buffer, int bufferLen, BOOL super);
typedef VOID (*PFNShowProgress)();
typedef VOID (*PFNHideProgress)();

typedef LONG (*PFNRegOpenKeyEx)(
						 __in        HKEY hKey,
						 __in_opt    LPCTSTR lpSubKey,
						 __reserved  DWORD ulOptions,
						 __in        REGSAM samDesired,
						 __out       PHKEY phkResult
						 );

typedef LONG (*PFNRegQueryValueEx)(
	_In_         HKEY hKey,
	_In_opt_     LPCTSTR lpValueName,
	__reserved   LPDWORD lpReserved,
	_Out_opt_    LPDWORD lpType,
	_Out_opt_    LPBYTE lpData,
	_Inout_opt_  LPDWORD lpcbData
	);

typedef LONG (*PFNRegCloseKey)(
						_In_  HKEY hKey
						);


typedef BOOL (*PFNShellExecuteEx)(
					_In_opt_  SHELLEXECUTEINFO *pExecInfo
					);

extern PFNShellExecuteEx pShellExecuteEx;
extern PFNRegQueryValueEx pRegQueryValueEx;
extern PFNRegOpenKeyEx pRegOpenKeyEx;
extern PFNRegCloseKey pRegCloseKey;

extern PFNCreateAppConfigObject pCreateAppConfigObject;
extern PFNInitAppRegisterInfo pInitAppRegisterInfo;
extern PFNCreateRegisterAppInfoObject pCreateRegisterAppInfoObject;
extern PFNGetAppRegisterInfoByExePath pGetAppRegisterInfoByExePath;
extern PFNGetAppRegisterInfoByinstallPath pGetAppRegisterInfoByinstallPath;
extern PFNGetConfigBySerialNum pGetConfigBySerialNum;
extern PFNIsOtherInstanceRunning pIsOtherInstanceRunning;
extern PFNGetTaxUsbManager pGetTaxUsbManager;
extern PFNGetPassword pGetPassword;
extern PFNShowProgress pShowProgress;
extern PFNHideProgress pHideProgress;

class DllWrapper
{
private:
	BOOL m_isInited;
	HMODULE m_hUsbManagerMod;
	HMODULE m_hUIMod;
	HMODULE m_hShell32;
	HMODULE m_hAdvapi32;
public:
	DllWrapper(void);
	~DllWrapper(void);
	BOOL Init();
	void Release();
};

extern DllWrapper g_dllWrapper;
